import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: mirac
 * Date: 2025-07-20
 * Time: 12:21
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();
        int ans = find(s);
        System.out.println(ans);
    }

    public static int find(String s) {
        int[] ch = new int[30];
        for (int i = 0; i < s.length(); i++) {
            ch[s.charAt(i) - 'a']++;
        }
        for (int i = 0; i < s.length(); i++) {
            if(ch[s.charAt(i) - 'a'] == 1) {
               return i;
            }
        }
        return -1;
    }
}
